


#include "mutator.h"



// GlobalMutator ::



GlobalMutator::GlobalMutator( CollectionSubjects *doors, CollectionCategories *catdoors, CollectionSubjects *people, CollectionCategories *catpeople )
    : m_DoorMutator(doors, catdoors)
    , m_PeopleMutator(people, catpeople)
{
}



bool GlobalMutator::check()
{
    return m_DoorMutator.check() && m_PeopleMutator.check();
}



bool GlobalMutator::isLikeInitial() const
{
    return m_DoorMutator.isLikeInitial() && m_PeopleMutator.isLikeInitial();
}



bool GlobalMutator::mutate()
{
    while(true)
    {
        if(m_DoorMutator.mutate())
        {
            if(m_PeopleMutator.mutate())
                return true;
        }
        if(!isLikeInitial())
            return false;
    }
}



void GlobalMutator::restore()
{
    m_DoorMutator.restore();
    m_PeopleMutator.restore();    
}
